<!DOCTYPE html>
<html  lang="zh-CN" >
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, maximum-scale=5, viewport-fit=cover">
    <title>ESP-IDF学习笔记-工程结构 | LO_StacNet的火柴盒</title>
    <meta name="description" content="ESP-IDF学习笔记-工程结构学习ESP-IDF的使用，首先得要学习一个IDF工程的结构。ESP-IDF的工程是以Cmake组织的，并使用了Ninja作为构建工具，这里只简单给出如何使用这套系统。">
<meta property="og:type" content="article">
<meta property="og:title" content="ESP-IDF学习笔记-工程结构">
<meta property="og:url" content="https://lostacnet.top/post/42346/">
<meta property="og:site_name" content="LO_StacNet的火柴盒">
<meta property="og:description" content="ESP-IDF学习笔记-工程结构学习ESP-IDF的使用，首先得要学习一个IDF工程的结构。ESP-IDF的工程是以Cmake组织的，并使用了Ninja作为构建工具，这里只简单给出如何使用这套系统。">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2023-04-23T08:46:54.000Z">
<meta property="article:modified_time" content="2023-05-29T15:37:47.754Z">
<meta property="article:author" content="LO_StacNet">
<meta property="article:tag" content="ESP-IDF">
<meta property="article:tag" content="ESP32">
<meta name="twitter:card" content="summary">

    
    <link rel="icon" href="/images/favicon.ico" type="image/x-icon">

    
<link rel="stylesheet" href="/css/common.min.css">



    
        <link href="//cdn.jsdelivr.net/npm/katex@0.9.0/dist/katex.min.css" rel="stylesheet">
    
    
    
    
        <link href="//cdn.jsdelivr.net/npm/lightgallery.js@1.1.3/dist/css/lightgallery.min.css" rel="stylesheet">
    
    
    
<link rel="stylesheet" href="/css/iconfont.min.css">

    
<meta name="generator" content="Hexo 6.3.0"><style>mjx-container[jax="SVG"] {
  direction: ltr;
}

mjx-container[jax="SVG"] > svg {
  overflow: visible;
}

mjx-container[jax="SVG"][display="true"] {
  display: block;
  text-align: center;
  margin: 1em 0;
}

mjx-container[jax="SVG"][justify="left"] {
  text-align: left;
}

mjx-container[jax="SVG"][justify="right"] {
  text-align: right;
}

g[data-mml-node="merror"] > g {
  fill: red;
  stroke: red;
}

g[data-mml-node="merror"] > rect[data-background] {
  fill: yellow;
  stroke: none;
}

g[data-mml-node="mtable"] > line[data-line] {
  stroke-width: 70px;
  fill: none;
}

g[data-mml-node="mtable"] > rect[data-frame] {
  stroke-width: 70px;
  fill: none;
}

g[data-mml-node="mtable"] > .mjx-dashed {
  stroke-dasharray: 140;
}

g[data-mml-node="mtable"] > .mjx-dotted {
  stroke-linecap: round;
  stroke-dasharray: 0,140;
}

g[data-mml-node="mtable"] > svg {
  overflow: visible;
}

[jax="SVG"] mjx-tool {
  display: inline-block;
  position: relative;
  width: 0;
  height: 0;
}

[jax="SVG"] mjx-tool > mjx-tip {
  position: absolute;
  top: 0;
  left: 0;
}

mjx-tool > mjx-tip {
  display: inline-block;
  padding: .2em;
  border: 1px solid #888;
  font-size: 70%;
  background-color: #F8F8F8;
  color: black;
  box-shadow: 2px 2px 5px #AAAAAA;
}

g[data-mml-node="maction"][data-toggle] {
  cursor: pointer;
}

mjx-status {
  display: block;
  position: fixed;
  left: 1em;
  bottom: 1em;
  min-width: 25%;
  padding: .2em .4em;
  border: 1px solid #888;
  font-size: 90%;
  background-color: #F8F8F8;
  color: black;
}

foreignObject[data-mjx-xml] {
  font-family: initial;
  line-height: normal;
  overflow: visible;
}

.MathJax path {
  stroke-width: 3;
}

mjx-container[display="true"] {
  overflow: auto hidden;
}

mjx-container[display="true"] + br {
  display: none;
}
</style></head>

    <body>
        <header class="header header-fixture">
    <div class="profile-search-wrap flex sm:block">
        
        
        <div class="profile sm:text-center md:px-1 lg:px-3 sm:pb-4 sm:pt-6">
            <a id="avatar" role="link" href="http://www.lostacnet.top" class="inline-block lg:w-16 lg:h-16 w-8 h-8 m-2" target="_blank" rel="noopener" rel="noreferrer" >
                <img src="/images/avatar.jpg" class="rounded-full" alt="avatar">
            </a>
            <h2 id="name" class="hidden lg:block">LO_StacNet</h2>
            <h3 id="title" class="hidden lg:block">电子玩家 &amp; 理想主义</h3>
            
            <small id="location" class="hidden lg:block">
                <i class="iconfont icon-map-icon"></i>
                Sichuan, China
            </small>
            
        </div>
        
        
<div class="search flex-1 flex lg:inline-block sm:hidden lg:px-4 lg:mt-2 lg:mb-4 lg:w-full">
    <form id="search-form" class="my-auto flex-1 lg:border lg:border-solid lg:border-gray-200">
        <div class="input-group table bg-gray-100 lg:bg-white w-full">
            <input id="search-input" type="text" placeholder="搜索" class="inline-block w-full bg-gray-100 lg:bg-white p-1">
            <span class="table-cell">
                <button name="search tigger button" disabled>
                    <i class="iconfont icon-search m-2"></i>
                </button>
            </span>
        </div>
    </form>
        
<div id="content-json" data-placeholder="搜索" class="invisible hidden">/content.json</div>
<script id="search-teamplate" type="text/html" data-path="/content.json">
    <div>
        <div class="search-header bg-gray-400">
            <input id="actual-search-input" model="keyword" ref="input" class="inline-block w-full h-10 px-2 py-1" placeholder="搜索" type="text">
        </div>
        <div class="search-result bg-gray-200">
            {{#each searchPosts}}
            <a href="/{{ path }}" class="result-item block px-2 pb-3 mb-1 pt-1 hover:bg-indigo-100">
                <i class="iconfont icon-file"></i>
                <h1 class="result-title inline font-medium text-lg">{{ title }}</h1>
                <p class="result-content text-gray-600 text-sm">{{{ text }}}</p>
            </a>
            {{/each}}
        </div>
    </div>
</script>

</div>


        <button name="menu toogle button" id="menu-toggle-btn" class="block sm:hidden p-3" role="button" aria-expanded="false">
            <i class="iconfont icon-hamburger"></i>
        </button>
    </div>
    <nav id="menu-nav" class="hidden sm:flex flex-col">
        
        
            <div class="menu-item menu-home" role="menuitem">
                <a href="/.">
                    <i class="iconfont icon-home" aria-hidden="true"></i>
                    <span class="menu-title">首页</span>
                </a>
            </div>
        
        
            <div class="menu-item menu-archives" role="menuitem">
                <a href="/archives">
                    <i class="iconfont icon-archive" aria-hidden="true"></i>
                    <span class="menu-title">归档</span>
                </a>
            </div>
        
        
            <div class="menu-item menu-categories" role="menuitem">
                <a href="/categories">
                    <i class="iconfont icon-folder" aria-hidden="true"></i>
                    <span class="menu-title">分类</span>
                </a>
            </div>
        
        
            <div class="menu-item menu-tags" role="menuitem">
                <a href="/tags">
                    <i class="iconfont icon-tag" aria-hidden="true"></i>
                    <span class="menu-title">标签</span>
                </a>
            </div>
        
        
            <div class="menu-item menu-links" role="menuitem">
                <a href="/links">
                    <i class="iconfont icon-friend" aria-hidden="true"></i>
                    <span class="menu-title">友链</span>
                </a>
            </div>
        
        
            <div class="menu-item menu-about" role="menuitem">
                <a href="/about">
                    <i class="iconfont icon-cup" aria-hidden="true"></i>
                    <span class="menu-title">关于</span>
                </a>
            </div>
        
        
<div class="social-links flex sm:flex-col lg:hidden mt-5">
    
        <span class="social-item text-center">
            <a target="_blank" rel="noopener" href="https://github.com/LOStacNet">
                <i class="iconfont social-icon icon-github"></i>
                <span class="menu-title hidden lg:inline">menu.github</span>
            </a>
        </span>
    
        <span class="social-item text-center">
            <a target="_blank" rel="noopener" href="https://gitee.com/LOStacNet">
                <i class="iconfont social-icon icon-project"></i>
                <span class="menu-title hidden lg:inline">menu.project</span>
            </a>
        </span>
    
</div>


    </nav>
</header>

        <section class="main-section">
            
    <main class="flex-1 px-4 py-14 md:px-5 lg:px-8 lg:py-4 relative min-h-screen">
    

    <article class="content article article-archives article-type-list" itemscope="">
        <header class="article-header">
            
    
        <h1 class="article-title text-lg" itemprop="name">
            ESP-IDF学习笔记-工程结构
        </h1>
    



            <p class="article-meta mb-3 text-xs">
                <span class="article-date">
    <i class="iconfont icon-calendar-check"></i>
	<a href="/post/42346/" class="article-date">
	  <time datetime="2023-04-23T08:46:54.000Z" itemprop="datePublished">4月 23</time>
	</a>
</span>

                
    <span class="article-category">
    <i class="iconfont icon-folder"></i>
    <a class="article-category-link" href="/categories/ESP32%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">ESP32学习笔记</a>
  </span>


                
    <span class="article-tags">
    <i class="iconfont icon-tag"></i>
    <a class="article-tag-none-link" href="/tags/ESP-IDF/" rel="tag">ESP-IDF</a>, <a class="article-tag-none-link" href="/tags/ESP32/" rel="tag">ESP32</a>
  </span>


                <span class="_partial/post-comment"><i class="icon icon-comment"></i>
                    <a href="/post/42346/#comments" class="article-comment-link">
                        评论
                    </a>
                </span>
                
    
        <span class="post-wordcount" itemprop="wordCount">字数统计: 1.3k(字)</span>
    
    
        <span class="post-readcount" itemprop="timeRequired">阅读时长: 5(分)</span>
    


            </p>
        </header>
        <div class="marked-body article-body">
            <h1 id="ESP-IDF学习笔记-工程结构"><a href="#ESP-IDF学习笔记-工程结构" class="headerlink" title="ESP-IDF学习笔记-工程结构"></a>ESP-IDF学习笔记-工程结构</h1><p>学习ESP-IDF的使用，首先得要学习一个IDF工程的结构。ESP-IDF的工程是以Cmake组织的，并使用了Ninja作为构建工具，这里只简单给出如何使用这套系统。</p>
<span id="more"></span>

<p><a target="_blank" rel="noopener" href="https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32s3/api-guides/build-system.html">官方文档</a></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/m0_50064262/article/details/118578051">参考于</a></p>
<h2 id="一，目录结构"><a href="#一，目录结构" class="headerlink" title="一，目录结构"></a>一，目录结构</h2><p>一个IDF工程一般有以下结构的目录：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">- myProject/</span><br><span class="line">             - CMakeLists.txt</span><br><span class="line">             - sdkconfig</span><br><span class="line">             - components/ - component1/ - CMakeLists.txt</span><br><span class="line">                                         - Kconfig</span><br><span class="line">                                         - src1.c</span><br><span class="line">                           - component2/ - CMakeLists.txt</span><br><span class="line">                                         - Kconfig</span><br><span class="line">                                         - src1.c</span><br><span class="line">                                         - include/ - component2.h</span><br><span class="line">             - main/       - CMakeLists.txt</span><br><span class="line">                           - src1.c</span><br><span class="line">                           - src2.c</span><br><span class="line"></span><br><span class="line">             - build/</span><br></pre></td></tr></table></figure>

<ul>
<li>顶层目录的<code>CMakeList.txt</code>：这是整个项目的CMake文件，其中引入了<code>/tools/cmake/project.cmake</code>用来构建其他部分。同时设置了工程名。</li>
<li><code>sdkconfig</code>：项目配置文件，使用<code>idf.py menuconfig</code>配置在IDE中对应设置按钮出现的菜单。在菜单中的配置以宏定义的方式出现在源码中。</li>
<li><code>main</code>：特殊的目录，包含项目本身的源码，被认为是mian组件。</li>
<li><code>build</code>：编译结果</li>
<li><code>components</code>：（可选）组件，即各种库。</li>
</ul>
<h3 id="项目CMakeLists"><a href="#项目CMakeLists" class="headerlink" title="项目CMakeLists"></a>项目CMakeLists</h3><p>该文件配置整个项目，通常十分小。<strong>最小情况</strong>如下:</p>
<figure class="highlight cmake"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">cmake_minimum_required</span>(VERSION <span class="number">3.16</span>)</span><br><span class="line"><span class="keyword">include</span>($ENV{IDF_PATH}/tools/cmake/<span class="keyword">project</span>.cmake)</span><br><span class="line"><span class="keyword">project</span>(myProject)</span><br></pre></td></tr></table></figure>

<ul>
<li><code>cmake_minimum_required(VERSION 3.16)</code> 必须放在 CMakeLists.txt 文件的第一行，它会告诉 CMake 构建该项目所需要的最小版本号。ESP-IDF 支持 CMake 3.16 或更高的版本。</li>
<li><code>include($ENV{IDF_PATH}/tools/cmake/project.cmake)</code> 会导入 CMake 的其余功能来完成配置项目、检索组件等任务。</li>
<li><code>project(myProject)</code> 会创建项目本身，并指定项目名称。该名称会作为最终输出的二进制文件的名字，即 <code>myProject.elf</code> 和 <code>myProject.bin</code>。每个 CMakeLists 文件只能定义一个项目。</li>
</ul>
<p>同时该文件可以配置一些全局变量用来修改默认值自定义构建系统：</p>
<blockquote>
<ul>
<li><code>COMPONENT_DIRS</code>：组件的搜索目录，默认为 <code>IDF_PATH/components</code>、 <code>PROJECT_DIR/components</code>、和 <code>EXTRA_COMPONENT_DIRS</code>。如果您不想在这些位置搜索组件，请覆盖此变量。</li>
<li><code>EXTRA_COMPONENT_DIRS</code>：用于搜索组件的其它可选目录列表。路径可以是相对于项目目录的相对路径，也可以是绝对路径。</li>
<li><code>COMPONENTS</code>：要构建进项目中的组件名称列表，默认为 <code>COMPONENT_DIRS</code> 目录下检索到的所有组件。使用此变量可以“精简”项目以缩短构建时间。请注意，如果一个组件通过 <code>COMPONENT_REQUIRES</code> 指定了它依赖的另一个组件，则会自动将其添加到 <code>COMPONENTS</code> 中，所以 <code>COMPONENTS</code> 列表可能会非常短。</li>
</ul>
</blockquote>
<p>使用 cmake 中的 set 命令 来设置这些变量，如 <code>set(VARIABLE "VALUE")</code>。请注意，set() 命令需放在<code>include(...)</code>之前，<code>cmake_minimum(...) </code>之后。</p>
<h3 id="组件CMakeList-txt"><a href="#组件CMakeList-txt" class="headerlink" title="组件CMakeList.txt"></a>组件CMakeList.txt</h3><p>组件是 COMPONENT_DIRS 列表中的任何包含<code>CMakeList.txt</code>目录。IDF按以下顺序搜索组件，如果<strong>有多个同名组件，以最后一个为准</strong>。</p>
<ol>
<li>搜索 ESP-IDF 内部组件（<code>$ENV{IDF_PATH}/components</code>）</li>
<li>搜索 <code>EXTRA_COMPONENT_DIRS</code> 中的组件</li>
<li>搜索项目组件（<code>$ENV{PROJECT_DIR}/components</code>）</li>
</ol>
<p>组件最小CMakeList如下：</p>
<figure class="highlight cmake"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">idf_component_register(	</span><br><span class="line">	SRCS 		   <span class="string">"foo.c"</span>	<span class="string">"cplus.cpp"</span></span><br><span class="line">	INCLUDE_DIRS   <span class="string">"include"</span></span><br><span class="line">)</span><br></pre></td></tr></table></figure>

<ul>
<li><code>SRCS</code>：源文件列表</li>
<li><code>INCLUDE_DIRS</code>：组件的include目录，会被添加到头文件搜索目录中</li>
</ul>
<p>除此之外，还有一些非必须的变量：</p>
<ul>
<li><p><code>REQUIRES</code>：申明组件的共用依赖，一般就是头文件中include的其他组件</p>
</li>
<li><p><code>PRIV_REQUIRES</code>：申明组件的私有依赖，一般是源文件中include的其他组件</p>
</li>
<li><p>….</p>
</li>
</ul>
<p>其中main也是一个组件，但其默认依赖所有组件。</p>
<h2 id="二，配置菜单"><a href="#二，配置菜单" class="headerlink" title="二，配置菜单"></a>二，配置菜单</h2><p>IDF中将组件的配置以<strong>宏定义</strong>的形式移出代码，放进idf的meunconfig中进行配置。在项目的任意位置，都可以使用<code>#include "sdkconfig.h“</code>进行访问。</p>
<h3 id="配置文件种类"><a href="#配置文件种类" class="headerlink" title="配置文件种类"></a>配置文件种类</h3><table>
<thead>
<tr>
<th align="center">文件名</th>
<th align="center">位置</th>
<th align="center">作用</th>
</tr>
</thead>
<tbody><tr>
<td align="center">Kconfig</td>
<td align="center">组件(手动创建)</td>
<td align="center">在<code>menuconfig</code>中的菜单中创建<code>Component Configuration</code>子菜单</td>
</tr>
<tr>
<td align="center">Kconfig.projbuild</td>
<td align="center">组件(手动创建)</td>
<td align="center">在<code>menuconfig</code>中创建顶层菜单</td>
</tr>
<tr>
<td align="center">sdkconfig</td>
<td align="center">工程(自动生成)</td>
<td align="center">保持配置</td>
</tr>
<tr>
<td align="center">sdkconfig.h</td>
<td align="center">工程编译文件(自动生成)</td>
<td align="center">配置的访问接口</td>
</tr>
<tr>
<td align="center">sdkconfig.default</td>
<td align="center">工程(手动创建)</td>
<td align="center">配置的默认值</td>
</tr>
<tr>
<td align="center">sdkconfig.old</td>
<td align="center">工程(自动生成)</td>
<td align="center">备份</td>
</tr>
<tr>
<td align="center">sdkconfig.ci</td>
<td align="center"></td>
<td align="center">用于单元测试</td>
</tr>
<tr>
<td align="center">sdkconfig.rename</td>
<td align="center"></td>
<td align="center">用于重命名弃用的配置名，方便旧配置文件快速用于新配置，兼容</td>
</tr>
</tbody></table>
<blockquote>
<p>sdkconfig.default可为不同设备添加默认配置,如:<code>sdkconfig.default.esp32s3</code></p>
</blockquote>
<h3 id="创建菜单"><a href="#创建菜单" class="headerlink" title="创建菜单"></a>创建菜单</h3><p><a target="_blank" rel="noopener" href="https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32s3/api-reference/kconfig.html">官方文档</a></p>
<p>创建菜单在<code>Kconfig</code>或者<code>Kconfig.projbuild</code>中按照特定语法进行创建。</p>
<p>具体语法可以参考<a target="_blank" rel="noopener" href="https://blog.csdn.net/m0_50064262/article/details/126540334?spm=1001.2014.3001.5502">这篇文章</a></p>
<p>这里直接给出该文章的中的例子：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line">menu "My menu"</span><br><span class="line"></span><br><span class="line">	# bool 是勾选框</span><br><span class="line">    config MY_TEST_BOOL</span><br><span class="line">        bool "bool_test"</span><br><span class="line">        help</span><br><span class="line">            This is a bool test.</span><br><span class="line">	</span><br><span class="line">	# int 是输入整数</span><br><span class="line">    config MY_TEST_INT</span><br><span class="line">        int "int_test"</span><br><span class="line">        default 12345</span><br><span class="line">        help</span><br><span class="line">            This is an int test.</span><br><span class="line">	</span><br><span class="line">	# hex 是输入16进制数</span><br><span class="line">    config MY_TEST_HEX</span><br><span class="line">        hex "hex_test"</span><br><span class="line">        default 0x7FFF</span><br><span class="line">        help</span><br><span class="line">            This is a hex test.</span><br><span class="line"></span><br><span class="line">	# tristate 在 ESP-IDF构建系统中会被当做 bool 处理</span><br><span class="line">    config MY_TEST_TRISTATE</span><br><span class="line">        tristate "tristate_test"</span><br><span class="line">        help</span><br><span class="line">            This is a tristate test.</span><br><span class="line"></span><br><span class="line">	# string 表示一个字符串</span><br><span class="line">    config MY_TEST_STRING</span><br><span class="line">        string "string_test"</span><br><span class="line">        help</span><br><span class="line">            This is a string test.</span><br><span class="line"></span><br><span class="line">endmenu</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>生成的宏定义是：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">define</span> CONFIG_MY_TEST_BOOL 1</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> CONFIG_MY_TEST_INT 12345</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> CONFIG_MY_TEST_HEX 0x7FFF</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> CONFIG_MY_TEST_STRING <span class="string">"ESP32 YYDS"</span></span></span><br></pre></td></tr></table></figure>

<p>宏定义的结构是:<code>CONFIG_+配置名</code></p>
<p>创建选项菜单:</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line">menu <span class="string">"My Menu"</span></span><br><span class="line"></span><br><span class="line">	choice MY_TEST_CHOICE</span><br><span class="line">	    prompt <span class="string">"My Test Choice"</span></span><br><span class="line">	    <span class="keyword">default</span> MY_CHOICE_OPTION1</span><br><span class="line">	    help</span><br><span class="line">	        This is a help.</span><br><span class="line">	</span><br><span class="line">	    config MY_CHOICE_OPTION1</span><br><span class="line">	        <span class="type">bool</span> <span class="string">"option1"</span></span><br><span class="line">	        help</span><br><span class="line">	            help <span class="keyword">for</span> option1</span><br><span class="line">	            </span><br><span class="line">	    config MY_CHOICE_OPTION2</span><br><span class="line">	        <span class="type">bool</span> <span class="string">"option2"</span></span><br><span class="line">	        help</span><br><span class="line">	        	help <span class="keyword">for</span> option2</span><br><span class="line">	        	</span><br><span class="line">	    config MY_CHOICE_OPTION3</span><br><span class="line">	        <span class="type">bool</span> <span class="string">"option3"</span></span><br><span class="line">	        help</span><br><span class="line">	        	help <span class="keyword">for</span> option3</span><br><span class="line">	endchoice</span><br><span class="line">endmenu</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>生成的宏定义：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">define</span> CONFIG_MY_CHOICE_OPTION_1</span></span><br></pre></td></tr></table></figure>


        </div>
        
<blockquote class="copyright">
    <p><strong>本文链接 : </strong><a class="permalink" href="https://lostacnet.top/post/42346/">https://lostacnet.top/post/42346/</a></p>
    <p><strong>This article is available under <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank" rel="noopener noreferrer">Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)</a> License  转载请注明出处</strong></p>
</blockquote>


    </article>
    
    <section id="comments">
        
    </section>


    

</main>


<aside style="" id="sidebar" class="aside aside-fixture">
    <div class="toc-sidebar">
        <nav id="toc" class="article-toc">
            <h3 class="toc-title">文章目录</h3>
            <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#ESP-IDF%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E5%B7%A5%E7%A8%8B%E7%BB%93%E6%9E%84"><span class="toc-number">1.</span> <span class="toc-text">ESP-IDF学习笔记-工程结构</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%80%EF%BC%8C%E7%9B%AE%E5%BD%95%E7%BB%93%E6%9E%84"><span class="toc-number">1.1.</span> <span class="toc-text">一，目录结构</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%A1%B9%E7%9B%AECMakeLists"><span class="toc-number">1.1.1.</span> <span class="toc-text">项目CMakeLists</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%BB%84%E4%BB%B6CMakeList-txt"><span class="toc-number">1.1.2.</span> <span class="toc-text">组件CMakeList.txt</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BA%8C%EF%BC%8C%E9%85%8D%E7%BD%AE%E8%8F%9C%E5%8D%95"><span class="toc-number">1.2.</span> <span class="toc-text">二，配置菜单</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E7%A7%8D%E7%B1%BB"><span class="toc-number">1.2.1.</span> <span class="toc-text">配置文件种类</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%9B%E5%BB%BA%E8%8F%9C%E5%8D%95"><span class="toc-number">1.2.2.</span> <span class="toc-text">创建菜单</span></a></li></ol></li></ol></li></ol>
        </nav>
    </div>
</aside>





        </section>
        <footer class="hidden lg:block fixed bottom-0 left-0 sm:w-1/12 lg:w-1/6 bg-gray-100 z-40">
    
    <div class="footer-social-links">
        
            <a target="_blank" rel="noopener" href="https://github.com/LOStacNet">
                <i class="iconfont icon-github"></i>
            </a>
        
            <a target="_blank" rel="noopener" href="https://gitee.com/LOStacNet">
                <i class="iconfont icon-project"></i>
            </a>
        
    </div>
    
    
</footer>

        <div id="mask" class="hidden mask fixed inset-0 bg-gray-900 opacity-75 z-40"></div>
        <div id="search-view-container" class="hidden shadow-xl"></div>
        
<script src="/js/dom-event.min.js"></script>



<script src="/js/local-search.min.js"></script>



    <script src="//cdn.jsdelivr.net/npm/lightgallery.js@1.1.3/dist/js/lightgallery.min.js"></script>
    
<script src="/js/light-gallery.min.js"></script>






    </body>
</html>
